package com.zhl.media.app.mvp.ui.fragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flyco.tablayout.SegmentTabLayout;
import com.flyco.tablayout.SlidingTabLayout;
import com.flyco.tablayout.listener.OnTabSelectListener;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.LogUtils;
import com.nineoldandroids.animation.Animator;
import com.nineoldandroids.animation.ObjectAnimator;
import com.orhanobut.hawk.Hawk;
import com.zhl.media.app.R;
import com.zhl.media.app.greendao.MediaPhotoDao;
import com.zhl.media.app.mvp.ui.activity.MainActivity;
import com.zhl.media.commonres.base.AppFragment;
import com.zhl.media.commonsdk.core.EventBusCode;

import org.simple.eventbus.Subscriber;

import java.util.ArrayList;

import butterknife.BindView;


public class TaskFragment extends AppFragment {

    private String[] titles = {"工作任务","广告画面"};

    private ArrayList<Fragment> mFragments = new ArrayList<>();

    @BindView(R.id.tl_2)
    SlidingTabLayout segmentTabLayout;
    @BindView(R.id.vp)
    ViewPager vp;
    @BindView(R.id.workDate)
    TextView workDate;
    @BindView(R.id.head)
    LinearLayout mLayout;
    private String date;
    public static TaskFragment newInstance() {
        Bundle args = new Bundle();
        TaskFragment fragment = new TaskFragment();
        fragment.setArguments(args);
        return fragment;
    }
    @Override
    public void setupFragmentComponent(@NonNull AppComponent appComponent) {}

    @Override
    public View initView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        date = Hawk.get("thisDate");
        View view = inflater.inflate(R.layout.task_fragment, container, false);
        return view;
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        workDate.setText(date);
        mFragments.add(WorkTaskFragment.newInstance());
        mFragments.add(FrameFragment.newInstance());
//        mFragments.add(MyTaskFragment.newInstance());
        vp.setAdapter(new MyPagerAdapter(getFragmentManager()));
        segmentTabLayout.setViewPager(vp);
    }
    @Override
    public void setData(@Nullable Object data) {
    }
    private class MyPagerAdapter extends FragmentPagerAdapter {
        public MyPagerAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public int getCount() {
            return mFragments.size();
        }

        @Override
        public CharSequence getPageTitle(int position) {
            return titles[position];
        }
        @Override
        public Fragment getItem(int position) {
            return mFragments.get(position);
        }
    }
}
